package com.itheima.work1123;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class Demo01 {
    public static void main(String[] args) throws Exception {
        read1();
        System.out.println("======");
        read2();
    }

    public static void read1() throws Exception {
        //TODO 一次读取一个字节
        FileInputStream file1 = new FileInputStream(new File("file.txt"));
        int ch = 0;
        while((ch = file1.read()) != -1){
            System.out.print((char)ch);
        }
        file1.close();
    }
    public static void read2() throws Exception {
        //TODO 一次读取多个字节
        FileInputStream file2 = new FileInputStream(new File("file.txt"));
        int ch = 0;
        byte[] buf = new byte[1024];
        while((ch = file2.read(buf)) != -1){
            System.out.print((char)ch);
        }
        file2.close();
    }
}
